package com.king.pattem.guardedsuspension;

/**
 * @author taomk
 * @version 1.0
 * @since 15-2-3 下午9:45
 */
public class ClientThread extends Thread {

	private RequestQueue requestQueue;

	public ClientThread(RequestQueue requestQueue, String name) {
		super(name);
		this.requestQueue = requestQueue;
	}

	public void run() {

		try {
			for (int i = 0; i < 10; i++) {
				Request request = new Request("RequestID : " + i + " Thread_Name : " + Thread.currentThread().getName());
				System.out.println(Thread.currentThread().getName() + " requests " + request);
				requestQueue.addRequest(request);
				Thread.sleep(10);
				System.out.println("ClientThread Name is : " + Thread.currentThread().getName());
			}
			System.out.println(Thread.currentThread().getName() + " request end");
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
